<?php
namespace app\service;
use think\facade\Db;
class visitorService{
	//访客添加
    public function visitorAdd($data){
        return Db::table("visitor")->insertGetId($data);
    }
    //根据Id查询访客
    public function visitorId($id){
    	return Db::table("visitor")->where("id",$id)->find();
    }

    //根据personGuid查询访客
    public function visitorGuid($personGuid){
        return Db::table("visitor")->where("personGuid",$personGuid)->where("state",'2')->find();
    }

    //
    public function visitorList($where,$page,$community_id){
    	return Db::name('visitor')->where("community_id","in",$community_id)->where($where)->order('id desc')->paginate(20, false, [
            'page'  =>  $page,
            'query' =>  $where
        ]);
    }
     public function visitorcount($where,$community_id){
    	return Db::name('visitor')->where("community_id","in",$community_id)->where($where)->count();
    }
}